{{define "content"}}
{{template "page_title" .}}
<div class="row">
    <div class="col-12">
        <form id="main" class="card" method="post">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-2">
                            <label class="form-label">昵称</label>
                            <input name="nickname" type="text" class="form-control" placeholder="请输入昵称" value="">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-2">
                            <label class="form-label">邮箱</label>
                            <input name="email" type="text" class="form-control" placeholder="请输入邮箱" value="">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-2">
                            <label class="form-label">手机号</label>
                            <input name="mobile" type="text" class="form-control" placeholder="请输入手机号" value="">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4">
                        <div class="mb-2">
                            <label class="form-label">密码</label>
                            <input name="password" type="text" class="form-control" placeholder="请输入密码" value="">
                        </div>
                    </div>
                </div>
            </div>
            <div class="card-footer">
                <button type="submit" class="btn btn-primary">提交</button>
                <a href="/user/list" class="btn btn-danger ml-2">返回</a>
            </div>
        </form>
    </div>
</div>
{{end}}
{{define "script"}}
<script type="text/javascript">
    $(document).ready(function () {
        $("#main").on("submit", function (event) {
            $('#main').ajaxSubmit({
                url: "/user/create",
                dataType: "json",
                timeout: 60000,
                success: function (data) {
                    if (data.code == 200) {
                        window.location.href = "/user/list";
                    } else {
                        alert(data.message);
                    }
                }
            })
            return false;
        });
    });
</script>
{{end}}